﻿
using DebIt.Common.Model;

namespace DebIt.ViewModel
{
    public class ClientEditViewModel : ViewModelBase
    {
        #region variables

        private Client _client;

        #endregion


        #region constructor
        
        public ClientEditViewModel(int id)
        {
            Client = id == 0 ? Service.NewClient() : Service.GetClient(id);
        }
       
        #endregion

        #region properties

        public Client Client
        {
            get { return _client; }
            set
            {
                if (_client == value) return;
                SendPropertyChanging(() => Client);
                _client = value;
                SendPropertyChanged(() => Client);
            }
        }

        #endregion


        #region method

        protected override void Load()
        {
        }

        public void Save()
        {
            Service.Update(Client);
        }
        #endregion
    }
}
